Skip to content

Fix crash for empty Annotated type application#21503

Open
cyphercodes wants to merge 2 commits into
python:masterfrom
cyphercodes:fix-annotated-empty-21471
Open

Fix crash for empty Annotated type application#21503
cyphercodes wants to merge 2 commits into
python:masterfrom
cyphercodes:fix-annotated-empty-21471

Conversation

@cyphercodes
Copy link
Copy Markdown

Fixes #21471.

Summary

  • Avoid special-casing Annotated[...] as its inner type when the subscript has no arguments.
  • Let the normal type analyzer report the existing Annotated[...] argument error instead of crashing.
  • Add a regression test for list[Annotated[()]] in type application context.

Tests

  • python3 -m pytest -n0 mypy/test/testcheck.py::TypeCheckSuite::check-annotated.test
  • python3 -m mypy --config-file mypy_self_check.ini -p mypy
  • python3 -m mypy /tmp/mypy21471.py --show-traceback
  • git diff --check

Prepared with AI assistance; I reviewed and verified the changes.

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexError: list index out of range with missing typing.Annotated type

1 participant